package com.mroapp.adapter;

import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;

import java.util.ArrayList;

/**
 * Created by apple on 16/7/12.
 */
public class GuideViewPagerAdapter extends PagerAdapter {
    private ArrayList<View> views;

    /**
     * @Description 引导页ViewPager adapter
     * @author <a href="http://t.cn/RvIApP5">ceychen</a>
     * @date 2014-5-23 下午5:54:10
     */
    public GuideViewPagerAdapter(ArrayList<View> views) {
        this.views = views;
    }


    @Override
    public int getCount() {
        if (views != null) {
            return views.size();
        }
        return 0;
    }
    /**
     * 初始化position 的界面
     */
    @Override
    public Object instantiateItem(View view, int position) {
        ((ViewPager) view).addView(views.get(position), 0);
        return views.get(position);
    }

    @Override
    public boolean isViewFromObject(View view, Object arg1) {
        return (view == arg1);
    }

    @Override
    public void destroyItem(View view, int position, Object arg2) {
        ((ViewPager) view).removeView(views.get(position));
    }
}
